﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.Common;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Caching;

using Husb.Data;
using Husb.DataUtil;


using ProcessTable = CentralOffice.Admin.Data.ApprovalProcessDataSet.ApprovalProcessDataTable;
using ProcessRow = CentralOffice.Admin.Data.ApprovalProcessDataSet.ApprovalProcessRow;

namespace CentralOffice.Admin.DataAccess
{
    public class ApprovalProcessAdapter : DataAccessAdapter<Admin.Data.ApprovalProcessDataSet, ProcessTable, ProcessRow>
    {
        public ApprovalProcessAdapter()
        {
            this.TableName = "ApprovalProcess";

            GetAllStoredProc = "Admin.ApprovalProcess_SelectApprovalProcessesAll";
            InsertStoredProc = "Admin.ApprovalProcess_InsertApprovalProces";
            UpdateStoredProc = "Admin.ApprovalProcess_UpdateApprovalProces";
            DeleteStoredProc = "Admin.ApprovalProcess_DeleteApprovalProces";


        }

        protected override void PopulateInsertParameters(Database db, DbCommand cmd)
        {
            db.AddInParameter(cmd, "Id", DbType.Guid, "Id", DataRowVersion.Current);
            db.AddInParameter(cmd, "ApprovalObject", DbType.Byte, "ApprovalObject", DataRowVersion.Current);
            db.AddInParameter(cmd, "Name", DbType.AnsiString, "Name", DataRowVersion.Current);

            db.AddInParameter(cmd, "Executor", DbType.AnsiString, "Executor", DataRowVersion.Current);
            db.AddInParameter(cmd, "UrgencyDegree", DbType.Int32, "UrgencyDegree", DataRowVersion.Current);
            

            db.AddInParameter(cmd, "IsDeleted", DbType.Boolean, "IsDeleted", DataRowVersion.Current);
            db.AddInParameter(cmd, "IsActive", DbType.Boolean, "IsActive", DataRowVersion.Current);
            db.AddInParameter(cmd, "CreatedTime", DbType.DateTime, "CreatedTime", DataRowVersion.Current);
            db.AddInParameter(cmd, "CreatedBy", DbType.Guid, "CreatedBy", DataRowVersion.Current);
            db.AddInParameter(cmd, "ModifiedTime", DbType.DateTime, "ModifiedTime", DataRowVersion.Current);
            db.AddInParameter(cmd, "LastModifiedBy", DbType.Guid, "LastModifiedBy", DataRowVersion.Current);
            db.AddInParameter(cmd, "Version", DbType.Int32, "Version", DataRowVersion.Current);
            db.AddInParameter(cmd, "Description", DbType.String, "Description", DataRowVersion.Current);
        }
    }
}
